/**
 * Created by FXY on 2017/12/5.
 */
import { Injectable } from '@angular/core';
import { Http }from '@angular/http';
import 'rxjs/add/operator/map';
import { environment } from '../../environments/environment'

@Injectable()
export class PriceService {
    prices: string[];
    url: string;

    constructor(public http: Http) {
        this.prices = [];
        this.url = environment.host + ":" + environment.port;
    }

    getPrices() {
        return this.http.get(this.url + "/price")
            .map(res => res.json());
    }

    addPrice(p) {
        return this.http.post(this.url + "/price/add", p)
            .map(res => res.json());
    }

    deletePrice(id) {
        return this.http.get(this.url + "/price/delete/" + id)
            .map(res => res.json());
    }

}
